/*
 * @lc app=leetcode.cn id=830 lang=golang
 *
 * [830] 较大分组的位置
 */
package Solutions

// @lc code=start
func largeGroupPositions(s string) [][]int {
	var currentChar rune = 0
	var l = -1
	pairs := make([][]int, 0, len(s)/2)
	for i, v := range s {
		if l == -1 {
			l = i
			currentChar = v
			continue
		}
		if v == currentChar {
			continue
		}
		if i-l >= 3 {
			pairs = append(pairs, []int{l, i - 1})
		}
		currentChar = v
		l = i
	}
	//加入最后一个
	if len(s)-l > 3 {
		pairs = append(pairs, []int{l, len(s) - 1})
	}
	return pairs

}

// @lc code=end
